package demo.DataStrucAndAlgo.Easy_pritice;

import java.util.Scanner;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/10/9-10-09-15:46
 * @Description：demo.DataStrucAndAlgo.Easy_pritice
 */
public class Test1360 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] grades = new int[num];
        int result = 0;
        for (int i = 0; i < grades.length; i++) {
            grades[i] = sc.nextInt();
            result = result + grades[i];
        }
        for (int i = 0; i < num-1; i++) {
            for (int j = i+1; j < num; j++) {
                result = result + (grades[i] | grades[j]);
            }
        }
        System.out.println(result);
    }
}
